package com.weixin.paleituo.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.bumptech.glide.Glide;
import com.weixin.paleituo.R;
import com.weixin.paleituo.activity.CheckstandActivity;
import com.weixin.paleituo.activity.GoodsStoreActivity;
import com.weixin.paleituo.activity.OrderDetailsActivity;
import com.weixin.paleituo.base.BaseOrderRecycleAdapter;
import com.weixin.paleituo.bean.GoodsListBean;
import com.weixin.paleituo.bean.OrderCreatedBean;
import com.weixin.paleituo.bean.StoreListBean;
import com.weixin.paleituo.util.StringUtils;
import com.weixin.paleituo.util.UIUtils;
import com.weixin.paleituo.view.MyHorizontalScrollView;

import java.util.ArrayList;
import java.util.List;

/**
 * Author yichao
 * Time  2018/4/7 17:51
 * Dest  待付款
 */

public class AwaitPayFoOrderRecycleAdapter extends BaseOrderRecycleAdapter {


    public AwaitPayFoOrderRecycleAdapter(Context context, List<StoreListBean> storeListBeans) {
        super(context, storeListBeans);
    }

    @Override
    protected void setNoCustomAwaitPayforData(NoCustomAwaitPayforViewHolder noCustomAwaitPayforViewHolder
            , final StoreListBean storeListBean
            , List<GoodsListBean> goodsList, int position) {
        String storeName = storeListBean.getStoreName();
        if (!StringUtils.isEmpty(storeName) && storeName.equals("舒社")) {
            noCustomAwaitPayforViewHolder.mIvIconItemOrderHead.setImageResource(R.mipmap.shushe_logo);
            noCustomAwaitPayforViewHolder.mTvStoreNameItemOrderHead.setText("舒社");
            noCustomAwaitPayforViewHolder.mIvMoreItemOrderHead.setVisibility(View.INVISIBLE);
        } else {
            noCustomAwaitPayforViewHolder.mIvMoreItemOrderHead.setVisibility(View.VISIBLE);
            noCustomAwaitPayforViewHolder.mIvIconItemOrderHead.setImageResource(R.mipmap.store_cart);
            noCustomAwaitPayforViewHolder.mTvStoreNameItemOrderHead.setText(storeListBean.getStoreName());
            noCustomAwaitPayforViewHolder.mLlStorerootItemOrderHead.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    GoodsStoreActivity.startActivity(mContext,storeListBean.getStoreId());
                }
            });
        }

        HorizontalScrollViewGoodsItemAdapter horizontalScrollViewGoodsItemAdapter=new HorizontalScrollViewGoodsItemAdapter(mContext, (ArrayList<GoodsListBean>) goodsList);

        noCustomAwaitPayforViewHolder.mIdHorizontalScrollViewItemNocustomAwaitfor.initDatas(horizontalScrollViewGoodsItemAdapter);
        noCustomAwaitPayforViewHolder.mTvPricestateItemOrderHead.setText("等待付款");
        noCustomAwaitPayforViewHolder.mTvGoodsnumberItemNocustomAwaitfor.setText("共" + storeListBean.getNum() + "件商品  需付款:");
        noCustomAwaitPayforViewHolder.mTvPaymoneyItemNocustomAwaitfor.setText("￥" + UIUtils.getMoney( storeListBean.getActualPrice()));
        noCustomAwaitPayforViewHolder.mIdHorizontalScrollViewItemNocustomAwaitfor.setOnItemClickListener(new MyHorizontalScrollView.OnItemClickListener() {
            @Override
            public void onClick(View view, int pos) {
                Intent intent = OrderDetailsActivity.call2OrderDetailsActivity(mContext, storeListBean.getId(), null);
                mContext.startActivity(intent);
            }
        });

        noCustomAwaitPayforViewHolder.mTvGopayforItemNocustom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                   OrderCreatedBean orderCreatedBean=new OrderCreatedBean();
                orderCreatedBean.setOrderId(storeListBean.getId());
                orderCreatedBean.setActualPrice(storeListBean.getActualPrice());
                Intent intent = CheckstandActivity.call2CheckstandActivity(mContext, 1, orderCreatedBean);
                mContext.startActivity(intent);
            }
        });
        noCustomAwaitPayforViewHolder.mLlNocustomRightLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = OrderDetailsActivity.call2OrderDetailsActivity(mContext, storeListBean.getId(),null);
                mContext.startActivity(intent);
            }
        });
    }
    @Override
    protected void setCustomAwaitPayforcData(CustomAwaitPayforViewHolder customAwaitPayforViewHolder, final StoreListBean storeListBean, List<GoodsListBean> goodsList, int position) {
        customAwaitPayforViewHolder.mTvStoreNameItemOrderHead.setText(storeListBean.getStoreName() + "");
        customAwaitPayforViewHolder.mTvPricestateItemOrderHead.setText("等待付款");
        Glide.with(mContext).load(goodsList.get(0).getListUrl()).into(customAwaitPayforViewHolder.mIvGoodsiconCustomForPricing);
        customAwaitPayforViewHolder.mTvMessgeCustomForPricing.setText(storeListBean.getMsg() + "");
        customAwaitPayforViewHolder.mTvGoodsnumberItemCustomAwaitfor.setText("共" + storeListBean.getNum() + "件商品  需付款:");
        customAwaitPayforViewHolder.mTvPayforMoneyItemCustomAwaitfor.setText("￥" + UIUtils.getMoney(storeListBean.getGoodsPrice()));
        customAwaitPayforViewHolder.mTvGopayforItemCustomAwaitfor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OrderCreatedBean orderCreatedBean=new OrderCreatedBean();
                orderCreatedBean.setOrderId(storeListBean.getId());
                orderCreatedBean.setActualPrice(storeListBean.getGoodsPrice());
               orderCreatedBean.setCouponMoney(storeListBean.getCuCouponMoney());
                Intent intent = CheckstandActivity.call2CheckstandActivity(mContext, 0, orderCreatedBean);
                mContext.startActivity(intent);
            }
        });
        customAwaitPayforViewHolder.mLlCustomconetRootLayoutOrderCustomConttent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = OrderDetailsActivity.call2OrderDetailsActivity(mContext, storeListBean.getId(),  "");
                mContext.startActivity(intent);

            }
        });
        customAwaitPayforViewHolder.mLlStorerootItemOrderHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GoodsStoreActivity.startActivity(mContext,storeListBean.getStoreId());
            }
        });
    }
    @Override
    protected void setCustomAwaitPricData(CustomAwaitPriceViewHolder customAwaitPriceViewHolder,
                                          final StoreListBean storeListBean, List<GoodsListBean> goodsList, int position) {
        customAwaitPriceViewHolder.mTvStoreNameItemOrderHead.setText(storeListBean.getStoreName() + "");
        customAwaitPriceViewHolder.mTvPricestateItemOrderHead.setText("等待定价");
        Glide.with(mContext).load(goodsList.get(0).getListUrl()).into(customAwaitPriceViewHolder.mIvGoodsiconCustomForPricing);
        customAwaitPriceViewHolder.mTvMessgeCustomForPricing.setText(storeListBean.getMsg() + "");
        customAwaitPriceViewHolder.mTvGoodsnumberCustomForPricing.setText("共" + storeListBean.getNum() + "件商品  需付款:");
        customAwaitPriceViewHolder.mTvAwaitpayforCustomForPricing.setText("￥待定");
        customAwaitPriceViewHolder.mLlStorerootItemOrderHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GoodsStoreActivity.startActivity(mContext,storeListBean.getStoreId());
            }
        });

        customAwaitPriceViewHolder.mLlCustomconetRootLayoutOrderCustomConttent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = OrderDetailsActivity.call2OrderDetailsActivity(mContext, storeListBean.getId(),"");
                mContext.startActivity(intent);

            }
        });

        customAwaitPriceViewHolder.mLlStorerootItemOrderHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GoodsStoreActivity.startActivity(mContext,storeListBean.getStoreId());
            }
        });

    }
}
